import 'package:flutter_massage/common_lib/index.dart';
import 'package:flutter_massage/pages/model/bean.dart';
import 'package:flutter_massage/pages/technician/technician_detail/technician_detail_page.dart';
import 'package:flutter_massage/service/index.dart';
import 'package:get/get.dart';

class StoreDetailLogic extends GetxController {
  final Shop bean;

  StoreDetailLogic(this.bean);

  @override
  void onReady() async {
    super.onReady();

    CommonObservable().addObserver(TechnicianDetailPage.keyListener, refreshPage);
    _refresh();
  }

  @override
  void onClose() {
    super.onClose();
    CommonObservable().removeObserver(TechnicianDetailPage.keyListener, refreshPage);
  }

  void refreshPage(key, [value]) {
    _refresh();
  }

  void _refresh() {
    List blackList = GetStorageService.blackList();
    for (var value in blackList) {
      (bean.shopTechnicians ?? []).removeWhere((element) => element.id == value);
    }
    update();
  }
}
